#ifndef QIHMESSAGEWINDOW_H
#define QIHMESSAGEWINDOW_H

#include "qihmessagewndclass.h"
#include <QObject>
#include "ihcore_global.h"

class QihMessageCallback
{ 
public:
	virtual ~QihMessageCallback() {};
	virtual LRESULT handleMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
	{
		return ::DefWindowProc(hwnd, message, wparam, lparam);
	}
};

class IHCORE_EXPORT QihMessageWindow
{
public:
	QihMessageWindow(QihMessageWndClass& pWndClass);
	~QihMessageWindow();

public:
	// internal window creation
	void create(); 
	void destroy(); 

	// 
	HWND handle() const { return _handle; }

	// callback management
	void registerCallback(quint32 msgid, QihMessageCallback* callback); 
	void registerCallback(quint32 beginMsgId, quint32 endMsgId, QihMessageCallback* callback); 
	void unregiserCallback(QihMessageCallback* callback); 
	void unregisterAllCallbacks();

	// 
	LRESULT dispatchMessage(UINT message, WPARAM wparam, LPARAM lparam);
private:
	struct CallbackRegInfo
	{
		quint32 firstMsgId;
		quint32 lastMsgId; 
		QihMessageCallback* callback;
	};
	QList<CallbackRegInfo* > _callbacks;
	HWND _handle;
};

#endif // QIHMESSAGEWINDOW_H
